home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / Z4CXBLD.C < prev    next >
C/C++ Source or Header  |  1995-08-21  |  5KB  |  153 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    z4cxbld.c
  5. //   Title:    9-Digit ZIP Code Directory -- on CD-ROM
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains the program entry point for
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <z4.h>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //    Stack size
  45. //----------------------------------------------------------------------------
  46. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  47. unsigned _stklen = 0x4000;
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //    Globals
  53. //----------------------------------------------------------------------------
  54.  
  55. //
  56. // A useless string which is simply embedded in the executable.
  57. //
  58. PSZ __pszCredits__ = "Written by John M Weeder, 1993";
  59.  
  60.  
  61. //
  62. //    This should contain a program description which will be displayed as
  63. //    part of the program's help text.
  64. //
  65. static PCSZ pcszDescription =
  66.     "This program builds the city/state cross reference.";
  67.  
  68. //
  69. //    Program command line options
  70. //
  71. static DATACFG dcfg;
  72. static BOOL fSort = FALSE;
  73. static BOOL fCompress = FALSE;
  74. static BOOL fIndex = FALSE;
  75. static BOOL fRecNo = FALSE;
  76. static BOOL fCheck = FALSE;
  77. static CHAR szConfig[MAX_PATH] = "z4cx";
  78. static BS_CMDOPT acmdopt[] =
  79.     {
  80.     { "CHECK",        (PVOID)&fCheck,        CMDOPT_TRUE,             "Validate CRC codes."},
  81.     { "COMPRESS",    (PVOID)&fCompress,    CMDOPT_TRUE,             "Compress data file."},
  82.     { "INDEX",        (PVOID)&fIndex,        CMDOPT_TRUE,             "Index data file."},
  83.     { "RECNO",        (PVOID)&fRecNo,        CMDOPT_TRUE,             "Process record count file."},
  84.     { "SORT",       (PVOID)&fSort,         CMDOPT_TRUE,             "Sort stripped data file."},
  85.     { "config",     (PVOID)szConfig,        CMDOPT_FILESPEC(80), "Configuration file name."},
  86.     BS_CMDOPT_NULL,
  87.     };
  88.  
  89.  
  90.  
  91. //----------------------------------------------------------------------------
  92. //   Description:    main() - Program entry point
  93. //    Parameters:    Standard C parameters
  94. //       Returns:    DOS return code.
  95. //----------------------------------------------------------------------------
  96. int main(int argc, char **argv)
  97. {
  98. static BS_CFG cfg = CFG_DFT;
  99.     int retval = 99;
  100.  
  101.     //
  102.     //    Initialize base library
  103.     //
  104.     BaseLibraryInitialize(argc, argv, &cfg);
  105.     BaseTitle("$Revision:  93.1  $", __DATE__, __TIME__, "ZIP+4 City Cross Reference File Build");
  106.     if (!BaseTitleHelp(acmdopt, pcszDescription,0))
  107.         return 99;
  108.  
  109.     DioSetDataPath(getenv("DATA"));
  110.     if (!DataConfigRead(szConfig, &dcfg))
  111.         {
  112.         Output("Failed reading configuration file.\n");
  113.         goto ERROR_EXIT;
  114.         }
  115.     if (fSort)
  116.        if (!DataSort(&dcfg))
  117.            {
  118.            Output("Failed sorting delimited data file.\n");
  119.            goto ERROR_EXIT;
  120.            }
  121.     if (fCompress)
  122.        if (!DataCompress(&dcfg, Z4CXCompress, DAC_RECNO))
  123.            {
  124.            Output("Failed compressing delimited data file.\n");
  125.            goto ERROR_EXIT;
  126.            }
  127.     if (fRecNo)
  128.         if (!DataRecNo(&dcfg))
  129.            {
  130.            Output("Failed generating record number index.\n");
  131.            return 99;
  132.            }
  133.     if (fIndex)
  134.         if (!DataIndex(&dcfg, Z4CXIndex))
  135.            {
  136.            Output("Failed indexing CS data file.\n");
  137.            return 99;
  138.            }
  139.     if (fCheck)
  140.         if (!DioCheck(dcfg.szData))
  141.            {
  142.            Output("Failed verifying data file.\n");
  143.            return 99;
  144.            }
  145.     retval = 0;
  146. ERROR_EXIT:
  147.     DioCloseAll();
  148.     return retval;
  149. }
  150. //----------------------------------------------------------------------------
  151. //------------------------------- End of File --------------------------------
  152. //----------------------------------------------------------------------------
  153.